import org.junit.Test;
import redis.clients.jedis.Jedis;

import java.util.List;
import java.util.Map;
import java.util.Set;

public class testRedis {
@Test
    public void testRedis(){

        Jedis jedis = new Jedis("127.0.0.1",6379);
        jedis.select(0);/*选择对应数据库*/
       /* String qq =jedis.get("dd");
        System.out.println(qq);*/

      // hash存值
    /*jedis.hset("User","name","张赞武");
    jedis.hset("User","age","2");
    jedis.hset("User","sex","老男人");

    Map<String, String> user = jedis.hgetAll("User");

    for (Map.Entry<String,String> entry:user.entrySet()) {
        System.out.println(entry.getKey()+"~~~~~~~~~~"+entry.getValue());
    }
*/
        //list存值
  /*  jedis.lpush("king","a","b","c","d","e");
    List<String> king = jedis.lrange("king", 0, 4);
    for (String string:king) {
        System.out.println(string);
    }
*/

 /* set存值*/
   /* jedis.sadd("seted","这他妈的");
    Set<String> seted = jedis.smembers("seted");
    for (String SS:seted) {
        System.out.println(SS);
    }
*/

//zset
    jedis.zadd("city",0 ,"大唐芙蓉园");
    jedis.zadd("city",1 ,"回民街");
    jedis.zadd("city",2 ,"秦岭野生动物园");
    Set<String> city = jedis.zrange("city", 0, 2);
    for (String pp:city) {
        System.out.println(pp);
    }


}

}
